<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增职称申报')" />
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-professional-add">
            <div class="row">
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-3 control-label is-required">申报类别：</label>
                        <div class="col-sm-8">
                            <select name="professionalType" class="form-control m-b" required th:with="type=${@dict.getType('professional_type')}">
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                            </select>
                        </div>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-3 control-label is-required">申报年度：</label>
                        <div class="col-sm-8">
                            <input type="text" class="form-control time-input" required data-type="year" name="professionalYear"/>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-3 control-label is-required">申报职称：</label>
                        <div class="col-sm-8">
                            <select name="professionalName" class="form-control m-b" required th:with="type=${@dict.getType('professional_name')}">
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                            </select>
                        </div>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-3 control-label is-required">申报职称等级：</label>
                        <div class="col-sm-8">
                            <select name="professionalLevel" class="form-control m-b" required th:with="type=${@dict.getType('basic_post_level')}">
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                            </select>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-3 control-label is-required">申报方式：</label>
                        <div class="col-sm-8">
                            <select name="professionalWay" class="form-control m-b" required th:with="type=${@dict.getType('professional_way')}">
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                            </select>
                        </div>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-3 control-label is-required">现从事专业：</label>
                        <div class="col-sm-8">
                            <select name="majorType" class="form-control m-b" required th:with="type=${@dict.getType('major_type')}">
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                            </select>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-3 control-label is-required">评审依据学历：</label>
                        <div class="col-sm-8">
                            <select name="educateType" class="form-control m-b" required th:with="type=${@dict.getType('basic_educate_name')}">
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                            </select>
                        </div>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-3 control-label is-required">依据学历取得时间：</label>
                        <div class="col-sm-8">
                            <div class="input-group date">
                                <input name="educateTime" class="form-control" placeholder="yyyy-MM-dd" type="text" required>
                                <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-3 control-label is-required">所学专业：</label>
                        <div class="col-sm-8">
                            <input name="educateMajor" class="form-control" type="text" required>
                        </div>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-3 control-label is-required">专业年限：</label>
                        <div class="col-sm-8">
                            <input name="majorYear" class="form-control" type="text" required>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-3 control-label is-required">继续教育是否合格：</label>
                        <div class="col-sm-8">
                            <select name="isPass" class="form-control m-b" required th:with="type=${@dict.getType('sys_yes_no')}">
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                            </select>
                        </div>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-3 control-label is-required">是否一线员工：</label>
                        <div class="col-sm-8">
                            <select name="isFront" class="form-control m-b" required th:with="type=${@dict.getType('sys_yes_no')}">
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                            </select>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-3 control-label is-required">是否担任过带教老师或教学秘书及时间：</label>
                        <div class="col-sm-8">
                            <select name="isTeacher" class="form-control m-b" required th:with="type=${@dict.getType('sys_yes_no')}">
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                            </select>
                        </div>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-3 control-label is-required">是否参加过支农、第一村医等活动及时间：</label>
                        <div class="col-sm-8">
                            <select name="isFarmer" class="form-control m-b" required th:with="type=${@dict.getType('sys_yes_no')}">
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                            </select>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-3 control-label is-required">继续教育及继续医学教育学分是否达到合格标准：</label>
                        <div class="col-sm-8">
                            <select name="isStandard" class="form-control m-b" required th:with="type=${@dict.getType('sys_yes_no')}">
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                            </select>
                        </div>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-3 control-label is-required">聘任现职务以来是否发生过医疗事故或投诉：</label>
                        <div class="col-sm-8">
                            <select name="isFailure" class="form-control m-b" required th:with="type=${@dict.getType('sys_yes_no')}">
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                            </select>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-3 control-label">学术兼职：</label>
                        <div class="col-sm-8">
                            <input name="plurality" class="form-control" type="text">
                        </div>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-3 control-label">备注：</label>
                        <div class="col-sm-8">
                            <input name="remark" class="form-control" type="text">
                        </div>
                    </div>
                </div>
            </div>
            <h4 class="form-header h4">论文或著作（最多三项）</h4>
            <div class="row">
                <div class="col-sm-12">
                    <button type="button" class="btn btn-white btn-sm" onclick="addColumn1()"><i class="fa fa-plus"> 增加</i></button>
                    <button type="button" class="btn btn-white btn-sm" onclick="delColumn1()"><i class="fa fa-minus"> 删除</i></button>
                    <div class="col-sm-12 select-table table-striped">
                        <table id="bootstrap-table1"></table>
                    </div>
                </div>
            </div>
            <h4 class="form-header h4">科研或专利（最多三项）</h4>
            <div class="row">
                <div class="col-sm-12">
                    <button type="button" class="btn btn-white btn-sm" onclick="addColumn2()"><i class="fa fa-plus"> 增加</i></button>
                    <button type="button" class="btn btn-white btn-sm" onclick="delColumn2()"><i class="fa fa-minus"> 删除</i></button>
                    <div class="col-sm-12 select-table table-striped">
                        <table id="bootstrap-table2"></table>
                    </div>
                </div>
            </div>
            <h4 class="form-header h4">荣誉（最多三项）</h4>
            <div class="row">
                <div class="col-sm-12">
                    <button type="button" class="btn btn-white btn-sm" onclick="addColumn3()"><i class="fa fa-plus"> 增加</i></button>
                    <button type="button" class="btn btn-white btn-sm" onclick="delColumn3()"><i class="fa fa-minus"> 删除</i></button>
                    <div class="col-sm-12 select-table table-striped">
                        <table id="bootstrap-table3"></table>
                    </div>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <script th:inline="javascript">
        var prefix = ctx + "record/professional"
        $("#form-professional-add").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#form-professional-add').serialize());
            }
        }

        $("input[name='educateTime']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $(function() {
            initTable1();
            initTable2();
            initTable3();
        });

        function initTable1() {
            var options = {
                id: "bootstrap-table1",
                pagination: false,
                showSearch: false,
                showRefresh: false,
                showToggle: false,
                showColumns: false,
                sidePagination: "client",
                columns: [{
                    checkbox: true
                },
                    {
                        field: 'index',
                        align: 'center',
                        title: "序号",
                        formatter: function (value, row, index) {
                            var columnIndex = $.common.sprintf("<input type='hidden' name='index' value='%s'>", $.table.serialNumber(index));
                            return columnIndex + $.table.serialNumber(index);
                        }
                    },
                    {
                        field: 'title',
                        align: 'center',
                        title: '名称',
                        formatter: function(value, row, index) {
                            var html = $.common.sprintf("<input class='form-control' type='text' name='info1List[%s].title' value='%s'>", index, value);
                            return html;
                        }
                    },
                    {
                        field: 'position',
                        align: 'center',
                        title: '位次',
                        formatter: function(value, row, index) {
                            var html = $.common.sprintf("<input class='form-control' type='text' name='into1List[%s].position' value='%s'>", index, value);
                            return html;
                        }
                    }]
            };
            $.table.init(options);
        }

        function addColumn1() {
            var count = $("#bootstrap-table1").bootstrapTable('getData').length;
            if(count < 3) {
                sub.editColumn();
                $("#bootstrap-table1").bootstrapTable('insertRow', {
                    index: count,
                    row: {
                        index: $.table.serialNumber(count),
                        title: "",
                        position: ""
                    }
                });
            } else {
                $.modal.alertError("最多可以添加三项");
                return;
            }
        }

        function delColumn1() {
            sub.editColumn();
            var ids = $.table.selectColumns("index");
            if (ids.length == 0) {
                $.modal.alertWarning("请至少选择一条记录");
                return;
            }
            $("#bootstrap-table1").bootstrapTable('remove', { field: "index", values: ids });
        }

        function initTable2() {
            var options = {
                id: "bootstrap-table2",
                pagination: false,
                showSearch: false,
                showRefresh: false,
                showToggle: false,
                showColumns: false,
                sidePagination: "client",
                columns: [{
                    checkbox: true
                },
                    {
                        field: 'index',
                        align: 'center',
                        title: "序号",
                        formatter: function (value, row, index) {
                            var columnIndex = $.common.sprintf("<input type='hidden' name='index' value='%s'>", $.table.serialNumber(index));
                            return columnIndex + $.table.serialNumber(index);
                        }
                    },
                    {
                        field: 'title',
                        align: 'center',
                        title: '名称',
                        formatter: function(value, row, index) {
                            var html = $.common.sprintf("<input class='form-control' type='text' name='info2List[%s].title' value='%s'>", index, value);
                            return html;
                        }
                    },
                    {
                        field: 'position',
                        align: 'center',
                        title: '位次',
                        formatter: function(value, row, index) {
                            var html = $.common.sprintf("<input class='form-control' type='text' name='into2List[%s].position' value='%s'>", index, value);
                            return html;
                        }
                    }]
            };
            $.table.init(options);
        }

        function addColumn2() {
            var count = $("#bootstrap-table2").bootstrapTable('getData').length;
            if(count < 3) {
                sub.editColumn();
                $("#bootstrap-table2").bootstrapTable('insertRow', {
                    index: count,
                    row: {
                        index: $.table.serialNumber(count),
                        title: "",
                        position: ""
                    }
                });
            } else {
                $.modal.alertError("最多可以添加三项");
                return;
            }
        }

        function delColumn2() {
            sub.editColumn();
            var ids = $.table.selectColumns("index");
            if (ids.length == 0) {
                $.modal.alertWarning("请至少选择一条记录");
                return;
            }
            $("#bootstrap-table2").bootstrapTable('remove', { field: "index", values: ids });
        }

        function initTable3() {
            var options = {
                id: "bootstrap-table3",
                pagination: false,
                showSearch: false,
                showRefresh: false,
                showToggle: false,
                showColumns: false,
                sidePagination: "client",
                columns: [{
                    checkbox: true
                },
                    {
                        field: 'index',
                        align: 'center',
                        title: "序号",
                        formatter: function (value, row, index) {
                            var columnIndex = $.common.sprintf("<input type='hidden' name='index' value='%s'>", $.table.serialNumber(index));
                            return columnIndex + $.table.serialNumber(index);
                        }
                    },
                    {
                        field: 'title',
                        align: 'center',
                        title: '名称',
                        formatter: function(value, row, index) {
                            var html = $.common.sprintf("<input class='form-control' type='text' name='info3List[%s].title' value='%s'>", index, value);
                            return html;
                        }
                    }]
            };
            $.table.init(options);
        }

        function addColumn3() {
            var count = $("#bootstrap-table3").bootstrapTable('getData').length;
            if(count < 3) {
                sub.editColumn();
                $("#bootstrap-table3").bootstrapTable('insertRow', {
                    index: count,
                    row: {
                        index: $.table.serialNumber(count),
                        title: ""
                    }
                });
            } else {
                $.modal.alertError("最多可以添加三项");
                return;
            }
        }

        function delColumn3() {
            sub.editColumn();
            var ids = $.table.selectColumns("index");
            if (ids.length == 0) {
                $.modal.alertWarning("请至少选择一条记录");
                return;
            }
            $("#bootstrap-table3").bootstrapTable('remove', { field: "index", values: ids });
        }
    </script>
</body>
</html>